home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Gooey1.3.1 / C++ Templates / mmAlert.c < prev    next >
Text File  |  1994-04-17  |  10KB  |  314 lines

  1. $$Loop Alerts
  2. $$Message MM Alert, mm:mmA_$Worksheet.name$.cp
  3.  
  4. $$File mm:mmA_$Worksheet.name$.cp
  5. /*  mmA_$Worksheet.name$                                 Handle this alert */
  6. /*  $CopyRight$ */
  7.  
  8. /*    File name:  mmA_$Worksheet.name$
  9.     Function:  Handle this alert.
  10. $$if Alert.Stop
  11.     This is a STOP alert, it is used to inform the user that data is about to be lost.
  12.     It is also used for fatal type errors and tells the user about the error.
  13. $$endif
  14. $$if Alert.Note
  15.     This is a NOTE alert, it is used to inform the user of some general information.
  16.     This alert is not used if there is a possibility of losing any data.
  17. $$endif
  18. $$if Alert.Caution
  19.     This is a CAUTION alert, it is used to inform the user that if the current path
  20.     is taken then data may be lost.  The user can change the present course and
  21.     save the data.  This is the type of alert used to tell the user that he needs to
  22.     save the data before going on.
  23. $$endif
  24.  
  25.     This alert is called when:
  26.  
  27.     The choices in this alert allow for:
  28.         
  29.     History: $Date$ Original by $Author$
  30.  
  31. */
  32.  
  33. #include "mmCommon$Prototype.name$.h"    /* Common */
  34. #include "Common$Prototype.name$.h"        /* Common */
  35.  
  36. /* ======================================================= */
  37. /* ======================================================= */
  38.  
  39. void CmmA$Worksheet.name$::Init()                    /* Initialize the alert variables */
  40. {
  41.  
  42.  
  43.     $$Loop Control.type = Button
  44. this->Enable_$Control.name$ = $Control.Active$;
  45.     $$EndLoop Control.type
  46.     $$Loop Control.type = Icon
  47. this->Enable_$Control.name$ = $Control.Active$;
  48.     $$EndLoop
  49.     $$Loop Control.type = Picture
  50.     $$if Control.NonGraphic
  51. this->Enable_$Control.name$ = $Control.Active$;
  52.     $$endif Control.NonGraphic
  53.     $$EndLoop
  54.     $$Loop Control.type = UButton
  55. this->Enable_$Control.name$ = $Control.Active$;
  56.     $$EndLoop
  57.     $$Loop Control.type = HotRect
  58. this->Enable_$Control.name$ = $Control.Active$;
  59.     $$EndLoop
  60.     $$Loop Control.type = Sicn
  61. this->Enable_$Control.name$ = $Control.Active$;
  62.     $$EndLoop
  63. }
  64.  
  65. /* ======================================================= */
  66.  
  67. void CmmA$Worksheet.name$::HandleFirstTime()    /* Handle setup necessary for first time in */
  68. {
  69. DialogPtr        theDialog;
  70. Rect            tempRect;
  71. long            LTemp;
  72.  
  73.  
  74. theDialog = this->theWindow;
  75.  
  76. $$Loop Control.type = Button
  77.     SetupNormalControl(theDialog,ResA_$Control.name$,this->Enable_$Control.name$,0);
  78.     $$if Control.Default
  79.     /* This is the default selection, when RETURN is pressed. */
  80.     HiliteDefaultButton(theDialog,ResA_$Control.name$);
  81.  
  82.     $$endif Control.Default
  83. $$EndLoop Control.type
  84. $$Loop Control.type = StaticText
  85. $$if Control.SpecialText
  86.     /* Draw static text, $Control.FullName$ */
  87.     $$if Control.TextColor ! Black
  88.     if (Has.ColorQD)                                        /* See if color QuickDraw is around */
  89.         {
  90.         DrawingColor.red = 0x$Control.RedTextColor$;
  91.         DrawingColor.green = 0x$Control.GreenTextColor$;
  92.         DrawingColor.blue = 0x$Control.BlueTextColor$;
  93.         RGBForeColor(&DrawingColor);                    /* Set the fore color */
  94.         RGBBackColor(&Saved_BackColor);                    /* Set the back color */
  95.         }
  96.     $$endif Control.TextColor
  97.     $$if Control.MultipleLine
  98.     SetRect(&tempRect,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);
  99.     DrawStaticTextBox(sResA_$Control.name$,&tempRect,$Control.TextAlignment$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
  100.     $$endif Control.MultipleLine
  101.     $$if Control.SingleLine
  102.     DrawStaticLine(sResA_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
  103.     $$endif Control.SingleLine
  104.     $$if Control.TextColor ! Black
  105.     if (Has.ColorQD)                                        /* See if color QuickDraw is around */
  106.         {
  107.         RGBForeColor(&Black_ForeColor);                    /* Set the fore color */
  108.         RGBBackColor(&White_BackColor);                    /* Set the back color */
  109.         }
  110.     $$endif Control.TextColor
  111.  
  112. $$endif
  113. $$EndLoop
  114. $$Loop Control.type = Icon
  115.     $$if Control.NonGraphic
  116.     /* Draw an Icon button */
  117.     SetupIconSicn(theDialog,ResA_$Control.name$,this->Enable_$Control.name$,ResA_N_$Control.name$,ResA_H_$Control.name$);
  118.  
  119.     $$endif Control.NonGraphic
  120. $$EndLoop
  121. $$Loop Control.type = Picture
  122.     $$if Control.NonGraphic
  123.     /* Draw a picture, $Control.FullName$ */
  124.     LTemp = ResA_N_$Control.name$;                        /* Picture ID and resize flag */
  125.     $$if Control.ClipPicture
  126.     LTemp = 0x00010000 | LTemp;
  127.     $$endif Control.ClipPicture
  128.     SetupTheItem(theDialog,ResA_$Control.name$,true,true,$Control.Active$,false,&tempRect,LTemp,0);/* Setup the Picture button */
  129.  
  130.     $$endif Control.NonGraphic
  131. $$EndLoop
  132. $$Loop Control.type = UButton
  133.     SetupPlugin(theDialog,ResA_$Control.name$,Enable_$Control.name$,
  134.         ResA_N_$Control.name$,ResA_H_$Control.name$,sResA_$Control.name$);
  135.     
  136. $$EndLoop
  137. $$Loop Control.type = Line
  138.     /* Draw a line, $Control.FullName$ */
  139.     $$if Control.GrayLine
  140.     PenPat(qd.gray);                                        /* Set the gray pen pattern */
  141.     $$endif Control.GrayLine
  142.     $$if Control.LineWidth ! 1
  143.     PenSize($Control.LineWidth$,$Control.LineWidth$);
  144.     $$endif Control.LineWidth
  145.     MoveTo($Control.LeftPosition$,$Control.TopPosition$);        /* Horz,vert, Move to starting position */
  146.     LineTo($Control.RightPosition$,$Control.BottomPosition$);    /* Horz,vert, Draw to the ending position */
  147.     $$if Control.LineWidth ! 1
  148.     PenSize(1,1);
  149.     $$endif Control.LineWidth
  150.     $$if Control.GrayLine
  151.     PenPat(qd.black);                                        /*  Back to default pen pattern  */
  152.     $$endif Control.GrayLine
  153.  
  154. $$EndLoop
  155. $$Loop Control.type = HotRect
  156.     /* Draw a Hotspot or Rectangle, $Control.FullName$ */
  157.     SetupHotSpot(theDialog,ResA_$Control.name$,$Control.MakeHotSpot$,$Control.LineWidth$,
  158.         $Control.ShadowWidth$,sResA_$Control.name$,Enable_$Control.name$);
  159.  
  160. $$EndLoop
  161. $$Loop Control.type = Sicn
  162.     /* Draw an Sicn */
  163. $$if Control.Graphic
  164.     SetupIconSicn(theDialog,ResA_$Control.name$,Enable_$Control.name$,ResA_N_$Control.name$,ResA_N_$Control.name$);
  165. $$endif Control.Graphic
  166. $$if Control.NonGraphic
  167.     SetupIconSicn(theDialog,ResA_$Control.name$,Enable_$Control.name$,ResA_N_$Control.name$,ResA_H_$Control.name$);
  168. $$endif Control.NonGraphic
  169.  
  170. $$EndLoop
  171.  
  172. this->DoFirstTime();
  173. }
  174.  
  175. /* ======================================================= */
  176. /* ======================================================= */
  177.  
  178. void CmmA$Worksheet.name$::BringUpAlert()
  179. {
  180. short        itemHit;                                /* Get the selection ID in here */
  181. AlertTHndl    AlertResHandle;                            /* Resource handle for Alert */
  182. Rect        tempRect;                                /* Temp rect for moving the alert */
  183. #if defined(powerc) || defined(__powerc)
  184. ModalFilterUPP    theFilter;
  185. #endif
  186.  
  187.  
  188. gCurrentAlert = g$Worksheet.name$;
  189.  
  190. AlertResHandle = (AlertTHndl)GetResource('ALRT',ResA_$Worksheet.name$);/* Get the Alerts resource template handle */
  191. HLock((Handle)AlertResHandle);                        /* Lock the resource down while we use it */
  192. $$if Worksheet.Center
  193. tempRect = (*AlertResHandle)->boundsRect;            /* Get the alerts position and size */
  194. $$if Worksheet.CenterHorz
  195. tempRect.left = ((screenRect.bounds.right - screenRect.bounds.left) - (tempRect.right - tempRect.left)) / 2;    /* Center Horz */
  196. $$endif Worksheet.CenterHorz
  197. $$if Worksheet.CenterVert
  198. tempRect.top = ((screenRect.bounds.bottom - screenRect.bounds.top) - (tempRect.bottom - tempRect.top)) / 3;    /* 1/3 vert */
  199. $$endif Worksheet.CenterVert
  200. tempRect.bottom = tempRect.top + ((*AlertResHandle)->boundsRect.bottom - (*AlertResHandle)->boundsRect.top);
  201. tempRect.right = tempRect.left + ((*AlertResHandle)->boundsRect.right - (*AlertResHandle)->boundsRect.left);
  202. (*AlertResHandle)->boundsRect = tempRect;            /* Place the centered position back in the template */
  203. $$endif
  204.  
  205. gCurrentAlert->DidFirstTime = FALSE;                /* Set the flag for the filter proc */
  206. $$Link    Worksheet.Open
  207.  
  208. /* Let the OS handle the Alert and wait for a result to be returned */
  209. #if defined(powerc) || defined(__powerc)
  210. theFilter = NewModalFilterProc(theAlertFilter);
  211. #endif
  212. $$if Alert.Stop
  213. #if defined(powerc) || defined(__powerc)
  214. itemHit = StopAlert(ResA_$Worksheet.name$,theFilter);        /* Bring in the alert resource */
  215. #else
  216. itemHit = StopAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&theAlertFilter);/* Bring in the alert resource */
  217. #endif
  218. $$endif
  219. $$if Alert.Note
  220. #if defined(powerc) || defined(__powerc)
  221. itemHit = NoteAlert(ResA_$Worksheet.name$,theFilter);        /* Bring in the alert resource */
  222. #else
  223. itemHit = NoteAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&theAlertFilter);/* Bring in the alert resource */
  224. #endif
  225. $$endif
  226. $$if Alert.Caution
  227. #if defined(powerc) || defined(__powerc)
  228. itemHit = CautionAlert(ResA_$Worksheet.name$,theFilter);        /* Bring in the alert resource */
  229. #else
  230. itemHit = CautionAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&theAlertFilter);/* Bring in the alert resource */
  231. #endif
  232. $$endif
  233. HUnlock((Handle)AlertResHandle);                    /* Release the alert handle to float */
  234.  
  235. $$Loop Control.type = Button
  236.     $$if Control.HasLinks
  237.     $$if Control.Default
  238. /* This is the default selection, when RETURN is pressed. */
  239.     $$endif
  240. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  241.     {
  242.     $$Link    Control.Select
  243.     }
  244.  
  245.     $$endif
  246. $$EndLoop Control.type
  247. $$Loop Control.type = Icon
  248.     $$if Control.HasLinks
  249.     $$if Control.NonGraphic
  250. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  251.     {
  252.     $$Link    Control.Select
  253.     }
  254.  
  255.     $$endif Control.NonGraphic
  256.     $$endif
  257. $$EndLoop
  258. $$Loop Control.type = Picture
  259.     $$if Control.HasLinks
  260.     $$if Control.NonGraphic
  261. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  262.     {
  263.     $$Link    Control.Select
  264.     }
  265.  
  266.     $$endif Control.NonGraphic
  267.     $$endif
  268. $$EndLoop
  269. $$Loop Control.type = UButton
  270.     $$if Control.HasLinks
  271. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  272.     {
  273.     $$Link    Control.Select
  274.     }
  275.  
  276.     $$endif
  277. $$EndLoop
  278. $$Loop Control.type = HotRect
  279.     $$if Control.HasLinks
  280.     $$if Control.HotSpot
  281. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  282.     {
  283.     $$Link    Control.Select
  284.     }
  285.  
  286.     $$endif Control.HotSpot
  287.     $$endif
  288. $$EndLoop
  289. $$Loop Control.type = Sicn
  290.     $$if Control.HasLinks
  291.     $$if Control.NonGraphic
  292. if (ResA_$Control.name$ == itemHit)                /* $Control.FullName$,See if this control was selected */
  293.     {
  294.     $$Link    Control.Select
  295.     }
  296.  
  297.     $$endif Control.NonGraphic
  298.     $$endif
  299. $$EndLoop
  300.  
  301. gCurrentAlert->DoItemHit(itemHit);                /* Tell the user routine which item was selected */
  302.  
  303. $$Link    Worksheet.Close
  304.  
  305. gCurrentAlert = nil;
  306. }
  307.  
  308. /* ======================================================= */
  309. /* ======================================================= */
  310. $$CloseFile
  311. $$EndLoop
  312.  
  313.  
  314.